import java.util.ArrayList;
import java.util.List;

class Solution18 {
    public List<List<Integer>> ret;
    public List<Integer> path;
    public int count,length;
    public List<List<Integer>> combine(int n, int k) {
        ret = new ArrayList<>();
        path = new ArrayList<>();
        count = k; length = n;
        dfs(1);
        return ret;
    }

    public  void dfs(int pos) {
        if(path.size() == count) {
            ret.add(new ArrayList<>(path));
            return;
        }
        for(int i = pos; i <= length; i++) {
            path.add(i);
            dfs(i+1);
            path.remove(path.size()-1);
        }
    }
}